package lib

import (
	"honeyweb/broker"
	"honeyweb/conf"
	"honeyweb/log"
	"os"
	"path"
)

func InitNats() {
	file := path.Join(configPath, "nats.toml")
	var c conf.NatsConf
	if  err := conf.ReadConfFromFile(file, &c); err == nil {
		broker.ConnectNats(&c)
		if err != nil {
			log.S().Errorf("nats connect err: %v", err)
			os.Exit(1)
		}
		broker.InitSubjects()
	} else {
		log.S().Errorf("nats connect err: %v", err)
		os.Exit(1)
	}
}

